package Math;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class MathMethod {
    public static void main(String[] args) {
        //Math方法
        //1.abs绝对值
        int abs = Math.abs(-9);
        System.out.println(abs);
        //2.Pow求幂
        double pow = Math.pow(2,4);
        System.out.println(pow);
        //3.ceil向上取证，返回>=该参数的最小整数(double类型)
        double ceil = Math.ceil(300.01);
        System.out.println(ceil);
        //4.floor向下取整
        double floor = Math.floor(3.6);
        System.out.println(floor);
        //5.round四舍五入
        long round = Math.round(-6.5);
        System.out.println(round);
        //6.sqrt开方
        double sqrt = Math.sqrt(9);
        System.out.println(sqrt);
        //7.random求随机数
        for (int i = 0;i<10;i++){
            System.out.println((int)(2 + Math.random() * 6));
        }
        //8.max,min
        double min = Math.min(1, 2.2);
        int max = Math.max(10, 28);
        System.out.println(min);
        System.out.println(max);

    }
}
